home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 52 / Amiga Format AFCD52 (Issue 136, May 2000).iso / -serious- / programming / basic / mildred / mildred.lha / lha / FDsExample4.lha / 2DPixelExplosion.asc next >
Text File  |  1999-01-21  |  3KB  |  100 lines

  1. ;Pixel Explosion Mildred Library Example.
  2. ;
  3. ;Programmed by : Mikkel Loekke, aka. FlameDuck.
  4. ;
  5. ;Please read the README file.
  6.  
  7. WBStartup
  8. NoCli
  9.  
  10. degrad.q = Pi/180
  11.  
  12. NEWTYPE .point
  13.   x.q
  14.   y.q
  15.   angl.w
  16.   vel.q
  17. End NEWTYPE
  18.  
  19. #numpnts=96*3                        ; Change this for more or less points.
  20.  
  21. Dim pnt.point (#numpnts)
  22.  
  23. DEFTYPE.l
  24.  
  25. MCPU Processor                      ; Tell Mildred which CPU it should use.
  26. Mc2pCPUmode Processor               ; Tell Mildred which CPU it should use for c2p.
  27.  
  28. MReserveBitmaps 1                   ; Tell Mildred that we're going to use 1 chunky bitmap.
  29. MReservec2pWindows 1                ; Tell it we only need one c2p display.
  30. MReserveShapes 1                    ; Tell Mildred that we need a shape aswell.
  31.  
  32. InitPalette 0,256                   ; Setup a grayscale palette.
  33. For t.l=0To 255
  34.   AGAPalRGB 0,t,t,t,t
  35. Next
  36.  
  37. .initgraphics
  38. MBitmap 0,320,256                   ; This will contain our chunky buffer.
  39.  
  40. Mc2pWindow 0,320,256                ; Setup structures for c2p conversions.
  41.  
  42. *pbb.l=AllocMem(320*256,$10002)     ; Get some free CHIP memory
  43. If *pbb.l                           ; and if we succeed
  44.   CludgeBitMap 0,320,256,8,*pbb     ; make it a planar bitmap.
  45. Else End
  46. EndIf
  47.  
  48. Dim scrtaglst.TagItem(7)            ; All this stuff sets up our
  49. scrtaglst(0)\ti_Tag = #SA_Left      ; Taglist for the screen we
  50. scrtaglst(0)\ti_Data = 0            ; want.
  51. scrtaglst(1)\ti_Tag = #SA_Depth
  52. scrtaglst(1)\ti_Data = 8
  53. scrtaglst(2)\ti_Tag = #SA_Width
  54. scrtaglst(2)\ti_Data = 320
  55. scrtaglst(3)\ti_Tag = #SA_Height
  56. scrtaglst(3)\ti_Data = 256
  57. scrtaglst(4)\ti_Tag = #SA_BitMap
  58. scrtaglst(4)\ti_Data = Addr BitMap (0)
  59. scrtaglst(5)\ti_Tag = #SA_ShowTitle
  60. scrtaglst(5)\ti_Data = 0
  61. scrtaglst(6)\ti_Tag = #SA_Draggable
  62. scrtaglst(6)\ti_Data = 0
  63. scrtaglst(7)\ti_Tag = #TAG_END      ; The most important tag of them all.
  64.  
  65. ScreenTags 0,"MildredDEMO",&scrtaglst(0) ; Open our intuition screen.
  66.  
  67. ShowPalette 0                       ; Attach our palette to the screen.
  68.  
  69.  
  70. .goagain                            ; A Label that tells us where to go
  71.                                     ; to reset all our variables
  72. For t.l=0To #numpnts
  73.   pnt(t)\x=160
  74.   pnt(t)\y=128
  75.   pnt(t)\angl=Rnd(359)
  76.   pnt(t)\vel=Rnd(3)+1
  77. Next
  78.  
  79. phase.w=0
  80. Repeat                              ; Repeat our mainloop ....
  81.   Mc2p *pbb                         ; Convert our chunky buffer to
  82.                                     ; our planar bitmap.
  83.   MCls                              ; Clear our chunky buffer
  84.   pntskip.w=0
  85.   For t=0 To #numpnts               ; Boring math part. It's really
  86.                                     ; not as complicated as it looks
  87.     If (pnt(t)\y>0 AND pnt(t)\y<256) AND (pnt(t)\x>0 AND pnt(t)\x<320)
  88.       MPlot pnt(t)\x,pnt(t)\y,255-phase
  89.       pnt(t)\x-Sin(pnt(t)\angl*degrad)*pnt(t)\vel
  90.       pnt(t)\y-Cos(pnt(t)\angl*degrad)*pnt(t)\vel
  91.     Else
  92.       pntskip+1
  93.     EndIf
  94.   Next
  95.   phase+4:If phase=256 Then pntskip=#numpnts
  96. Until RawStatus($45) OR pntskip=#numpnts  ; .... Until we press Escape, or the fade is complete.
  97. If pntskip=#numpnts Then Goto goagain     ; If the fade completed, reset variables, and go again.
  98. End                                 ; End our nice program.
  99.  
  100.